<!DOCTYPE HTML>
<html lang="zh-CN">


<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="keywords" content="【4G模块】移远4G模组拨号+socket获取天气数据, ZhengN_Blog">
    <meta name="description" content="上一篇分享了4G开发板与我们PC进行通信（需要进行内网穿透），这一篇笔记我们直接使用4G开发板访问天气服务器获取天气数据。
我们要使用移远4G模块进行网络通信，要经历 3 个主要过程：网络注册、网络激活和socket 创建。
网络注册是自动">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>【4G模块】移远4G模组拨号+socket获取天气数据 | ZhengN_Blog</title>
    <link rel="icon" type="image/jpeg" href="/favicon.jpg">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    <style type="text/css">
        
    </style>

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">ZhengN_Blog</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>首页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>归档</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>关于</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>友情链接</span>
        </a>
    </li>
    
    <li>
        <a href="#searchModal" class="modal-trigger waves-effect waves-light">
            <i id="searchIcon" class="fa fa-search" title="搜索"></i>
        </a>
    </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">ZhengN_Blog</div>
        <div class="logo-desc">
            
            printf(&#34;每天进步一点点~&#34;);
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                首页
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                归档
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                关于
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                友情链接
            </a>
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/zhengnianli/stm32_weather" class="waves-effect waves-light" target="_blank">
                <i class="fa fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/zhengnianli/stm32_weather" class="github-corner tooltipped hide-on-med-and-down" target="_blank" data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewbox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/>
    </svg>
</a>
        
    </nav>

</header>





<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/8.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        【4G模块】移远4G模组拨号+socket获取天气数据
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 20px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/内网穿透/" target="_blank">
                                <span class="chip bg-color">内网穿透</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fa fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/嵌入式/" class="post-category" target="_blank">
                                嵌入式
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                <div class="post-date info-break-policy">
                    <i class="fa fa-calendar-minus-o fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-06-25
                </div>

                
                    
                    <div class="info-break-policy">
                        <i class="fa fa-file-word-o fa-fw"></i>文章字数:&nbsp;&nbsp;
                        2.3k
                    </div>
                    

                    
                    <div class="info-break-policy">
                        <i class="fa fa-clock-o fa-fw"></i>阅读时长:&nbsp;&nbsp;
                        11 分
                    </div>
                    
                
				
				
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="fa fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>上一篇分享了<a href="https://t.1yb.co/13rF" target="_blank" rel="noopener">4G开发板与我们PC进行通信</a>（需要进行内网穿透），这一篇笔记我们直接使用4G开发板访问天气服务器获取天气数据。</p>
<p>我们要使用移远4G模块进行网络通信，要经历 3 个主要过程：<code>网络注册</code>、<code>网络激活</code>和<code>socket 创建</code>。</p>
<p>网络注册是自动完成的，无需用户代码干预（网络注册前，请确认 SIM 卡是否正常识别且 SIM 卡无欠费等业务异常）。只有在网络注册成功以后，才可进行网络激活，即本文所述的拨号（下文皆称为拨号）。只有拨号成功后，才可进行 socket 网络通信。</p>
<h3 id="拨号-socket-通信基本流程"><a href="#拨号-socket-通信基本流程" class="headerlink" title="拨号+socket 通信基本流程"></a>拨号+socket 通信基本流程</h3><p><img src="https://s1.ax1x.com/2020/07/03/Nvi3yq.png" alt></p>
<p>确保拨号成功的必要条件：SIM 卡没欠费； 硬件良好，天线匹配；拨号前，调用 ql_network_register_wait 等待网络注册成功；拨号时，向 ql_start_data_call 传递正确的参数。</p>
<h3 id="Socket-通信流程"><a href="#Socket-通信流程" class="headerlink" title="Socket 通信流程"></a>Socket 通信流程</h3><p><img src="https://s1.ax1x.com/2020/07/03/Nvi1ln.png" alt></p>
<p>EC100 模块 Socket 通信基本流程如上图：<br>1、在进行 socket 通信之前，必须确保拨号已经成功，可以通过 ql_get_data_call_info()查询需要进行 socket 通信的网络通道是否拨号成功。<br>2、拨号成功后进行 socket 通信时，必须对需要通信的网络通道进行 bind 操作。不管是 UDP 还是 TCP，都必须执行 Bind 操作之后才可以正常进行 socket 通信。</p>
<p>sdk中给我们提供了一个<code>tcp_client</code>的demo，这个demo的设计思路完全按照上面两张图流程图来设计。我们在这个demo进行修改，获取天气数据。</p>
<p>我们修改后的<code>example_tcp_weather_client.c</code>代码如下：</p>
<pre class=" language-c"><code class="language-c"><span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;string.h></span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;stdlib.h></span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"ql_type.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"ql_rtos.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"ql_application.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"ql_data_call.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"sockets.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"netdb.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"cJSON.h"</span></span>

<span class="token macro property">#<span class="token directive keyword">define</span>  DEBUG   0        </span>

<span class="token comment" spellcheck="true">/* 心知天气（www.seniverse.com）IP及端口 */</span>
<span class="token macro property">#<span class="token directive keyword">define</span>  WEATHER_IP_ADDR   "116.62.81.138"</span>
<span class="token macro property">#<span class="token directive keyword">define</span>  WEATHER_PORT       80</span>

<span class="token macro property">#<span class="token directive keyword">define</span> TCP_CONNECT_TIMEOUT_S 10</span>
<span class="token macro property">#<span class="token directive keyword">define</span> TCP_RECV_TIMEOUT_S 10</span>
<span class="token macro property">#<span class="token directive keyword">define</span> TCP_CLOSE_LINGER_TIME_S 10</span>
<span class="token macro property">#<span class="token directive keyword">define</span> TCP_CLIENT_SEND_STR "tcp client send string"</span>
<span class="token macro property">#<span class="token directive keyword">define</span> PROFILE_IDX 1</span>
<span class="token macro property">#<span class="token directive keyword">define</span> PROFILE_IDX 1</span>

<span class="token comment" spellcheck="true">/* 秘钥，注意！！如果要用这一份代码，这个一定要改为自己的，因为这个我已经故意改错了，防止有人与我公用一个KEY */</span>
<span class="token macro property">#<span class="token directive keyword">define</span>  KEY    "2owqvhhd2dd9o9f9"        </span><span class="token comment" spellcheck="true">// 这是在心知天气注册后，每个用户自己的一个key</span>

<span class="token comment" spellcheck="true">/* GET请求包 */</span>
<span class="token macro property">#<span class="token directive keyword">define</span>  GET_REQUEST_PACKAGE     \
         "GET https://api.seniverse.com/v3/weather/%s.json?key=%s&amp;location=%s&amp;language=zh-Hans&amp;unit=c\r\n\r\n"</span>

<span class="token comment" spellcheck="true">/* JSON数据包 */</span>    
<span class="token macro property">#<span class="token directive keyword">define</span>  NOW_JSON     "now"</span>
<span class="token comment" spellcheck="true">//....还用更多其他的天气数据包可查阅心知天气</span>

<span class="token comment" spellcheck="true">/* 天气数据结构体 */</span>
<span class="token keyword">typedef</span> <span class="token keyword">struct</span>
<span class="token punctuation">{</span>
    <span class="token comment" spellcheck="true">/* 实况天气数据 */</span>
    <span class="token keyword">char</span> id<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>                <span class="token comment" spellcheck="true">//id</span>
    <span class="token keyword">char</span> name<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>                <span class="token comment" spellcheck="true">//地名</span>
    <span class="token keyword">char</span> country<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>            <span class="token comment" spellcheck="true">//国家</span>
    <span class="token keyword">char</span> path<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>                <span class="token comment" spellcheck="true">//完整地名路径</span>
    <span class="token keyword">char</span> timezone<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>            <span class="token comment" spellcheck="true">//时区</span>
    <span class="token keyword">char</span> timezone_offset<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>   <span class="token comment" spellcheck="true">//时差</span>
    <span class="token keyword">char</span> text<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>                <span class="token comment" spellcheck="true">//天气预报文字</span>
    <span class="token keyword">char</span> code<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>                <span class="token comment" spellcheck="true">//天气预报代码</span>
    <span class="token keyword">char</span> temperature<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>       <span class="token comment" spellcheck="true">//气温</span>
    <span class="token keyword">char</span> last_update<span class="token punctuation">[</span><span class="token number">32</span><span class="token punctuation">]</span><span class="token punctuation">;</span>        <span class="token comment" spellcheck="true">//最后一次更新的时间</span>
<span class="token punctuation">}</span>Weather<span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// 全局变量</span>
<span class="token keyword">static</span> <span class="token keyword">struct</span> in_addr ip4_addr <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// 函数声明</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">GetWeather</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>weather_json<span class="token punctuation">,</span> <span class="token keyword">char</span> <span class="token operator">*</span>location<span class="token punctuation">,</span> Weather <span class="token operator">*</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">static</span> <span class="token keyword">int</span> <span class="token function">cJSON_NowWeatherParse</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>JSON<span class="token punctuation">,</span> Weather <span class="token operator">*</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">static</span> <span class="token keyword">int</span> <span class="token function">cJSON_DailyWeatherParse</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>JSON<span class="token punctuation">,</span> Weather <span class="token operator">*</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">DisplayWeather</span><span class="token punctuation">(</span>Weather <span class="token operator">*</span>weather_data<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">ql_nw_status_callback</span><span class="token punctuation">(</span><span class="token keyword">int</span> profile_idx<span class="token punctuation">,</span> <span class="token keyword">int</span> nw_status<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">datacall_satrt</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">/*******************************************************************************************************
** 函数: sockets_weather_test
**------------------------------------------------------------------------------------------------------
** 参数: void
** 返回: void
********************************************************************************************************/</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">sockets_weather_test</span><span class="token punctuation">(</span><span class="token keyword">void</span> <span class="token operator">*</span> argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword">struct</span> ql_data_call_info info <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token keyword">char</span> ip4_addr_str<span class="token punctuation">[</span><span class="token number">16</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
    Weather weather_data <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token keyword">char</span> <span class="token operator">*</span>location <span class="token operator">=</span> <span class="token string">"shenzhen"</span><span class="token punctuation">;</span>

    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"========== sockets tcp test will start ...\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment" spellcheck="true">/* 拨号开始 */</span>
    <span class="token function">datacall_satrt</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment" spellcheck="true">/* 获取拨号信息 */</span>
    <span class="token function">ql_get_data_call_info</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>info<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"info.profile_idx: %d\r\n"</span><span class="token punctuation">,</span> info<span class="token punctuation">.</span>profile_idx<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"info.ip_version: %d\r\n"</span><span class="token punctuation">,</span> info<span class="token punctuation">.</span>ip_version<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"info.v4.state: %d\r\n"</span><span class="token punctuation">,</span> info<span class="token punctuation">.</span>v4<span class="token punctuation">.</span>state<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"info.v4.reconnect: %d\r\n"</span><span class="token punctuation">,</span> info<span class="token punctuation">.</span>v4<span class="token punctuation">.</span>reconnect<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">inet_ntop</span><span class="token punctuation">(</span>AF_INET<span class="token punctuation">,</span> <span class="token operator">&amp;</span>info<span class="token punctuation">.</span>v4<span class="token punctuation">.</span>addr<span class="token punctuation">.</span>ip<span class="token punctuation">,</span> ip4_addr_str<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>ip4_addr_str<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"info.v4.addr.ip: %s\r\n"</span><span class="token punctuation">,</span> ip4_addr_str<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">inet_ntop</span><span class="token punctuation">(</span>AF_INET<span class="token punctuation">,</span> <span class="token operator">&amp;</span>info<span class="token punctuation">.</span>v4<span class="token punctuation">.</span>addr<span class="token punctuation">.</span>pri_dns<span class="token punctuation">,</span> ip4_addr_str<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>ip4_addr_str<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"info.v4.addr.pri_dns: %s\r\n"</span><span class="token punctuation">,</span> ip4_addr_str<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">inet_ntop</span><span class="token punctuation">(</span>AF_INET<span class="token punctuation">,</span> <span class="token operator">&amp;</span>info<span class="token punctuation">.</span>v4<span class="token punctuation">.</span>addr<span class="token punctuation">.</span>sec_dns<span class="token punctuation">,</span> ip4_addr_str<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>ip4_addr_str<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"info.v4.addr.sec_dns: %s\r\n"</span><span class="token punctuation">,</span> ip4_addr_str<span class="token punctuation">)</span><span class="token punctuation">;</span>

    ip4_addr <span class="token operator">=</span> info<span class="token punctuation">.</span>v4<span class="token punctuation">.</span>addr<span class="token punctuation">.</span>ip<span class="token punctuation">;</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>info<span class="token punctuation">.</span>v4<span class="token punctuation">.</span>state<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">memset</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>weather_data<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>weather_data<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment" spellcheck="true">// weather_data清零 </span>
        <span class="token function">GetWeather</span><span class="token punctuation">(</span>NOW_JSON<span class="token punctuation">,</span> location<span class="token punctuation">,</span> <span class="token operator">&amp;</span>weather_data<span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment" spellcheck="true">// GET 并解析实况天气数据</span>
        <span class="token function">DisplayWeather</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>weather_data<span class="token punctuation">)</span><span class="token punctuation">;</span>                     <span class="token comment" spellcheck="true">// 显示天气结果</span>
    <span class="token punctuation">}</span>

    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"========== sockets tcp test finished\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">ql_nw_status_callback</span><span class="token punctuation">(</span><span class="token keyword">int</span> profile_idx<span class="token punctuation">,</span> <span class="token keyword">int</span> nw_status<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"profile(%d) status: %d\r\n"</span><span class="token punctuation">,</span> profile_idx<span class="token punctuation">,</span> nw_status<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">datacall_satrt</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"wait for network register done\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment" spellcheck="true">/* 等待网络注册结果 */</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token function">ql_network_register_wait</span><span class="token punctuation">(</span><span class="token number">120</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** network register fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"doing network activing ...\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token function">ql_wan_start</span><span class="token punctuation">(</span>ql_nw_status_callback<span class="token punctuation">)</span><span class="token punctuation">;</span>            <span class="token comment" spellcheck="true">/* 拨号初始化：注册拨号回调函数 */</span>
        <span class="token function">ql_set_auto_connect</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> TRUE<span class="token punctuation">)</span><span class="token punctuation">;</span>                    <span class="token comment" spellcheck="true">/* 设置拨号掉线是否自动重连 */</span>
        <span class="token function">ql_start_data_call</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment" spellcheck="true">/* 开始拨号 */</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">GetWeather</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>weather_json<span class="token punctuation">,</span> <span class="token keyword">char</span> <span class="token operator">*</span>location<span class="token punctuation">,</span> Weather <span class="token operator">*</span>result<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword">int</span>                sock_nbio    <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span>                ret            <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span>                sock_fd     <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span>                sock_error  <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    socklen_t        optlen <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    fd_set             read_fds<span class="token punctuation">,</span> write_fds<span class="token punctuation">;</span>
    <span class="token keyword">struct</span> timeval    t<span class="token punctuation">;</span>
    <span class="token keyword">struct</span> addrinfo        <span class="token operator">*</span> res<span class="token punctuation">,</span> hints<span class="token punctuation">;</span>
    <span class="token keyword">struct</span> sockaddr_in    <span class="token operator">*</span> ip4_svr_addr<span class="token punctuation">;</span>
    <span class="token keyword">struct</span> sockaddr_in    ip4_local_addr <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
    u8 dns_success <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    u8 recv_buf<span class="token punctuation">[</span><span class="token number">128</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
    u8 GetRequestBuf<span class="token punctuation">[</span><span class="token number">256</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
    u8 WeatherRecvBuf<span class="token punctuation">[</span><span class="token number">2</span><span class="token operator">*</span><span class="token number">1024</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token comment" spellcheck="true">/*  */</span>
    <span class="token function">memset</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>hints<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span><span class="token keyword">struct</span> addrinfo<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    hints<span class="token punctuation">.</span>ai_family <span class="token operator">=</span> AF_INET<span class="token punctuation">;</span>
    hints<span class="token punctuation">.</span>ai_socktype <span class="token operator">=</span> SOCK_STREAM<span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token function">getaddrinfo_with_pcid</span><span class="token punctuation">(</span>WEATHER_IP_ADDR<span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>hints<span class="token punctuation">,</span> <span class="token operator">&amp;</span>res<span class="token punctuation">,</span> PROFILE_IDX<span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** DNS fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    dns_success <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>

    ret <span class="token operator">=</span> <span class="token function">socket</span><span class="token punctuation">(</span>AF_INET<span class="token punctuation">,</span> SOCK_STREAM<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** socket create fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    sock_fd <span class="token operator">=</span> ret<span class="token punctuation">;</span>

    <span class="token function">ioctl</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> FIONBIO<span class="token punctuation">,</span> <span class="token operator">&amp;</span>sock_nbio<span class="token punctuation">)</span><span class="token punctuation">;</span>

    ip4_local_addr<span class="token punctuation">.</span>sin_family <span class="token operator">=</span> AF_INET<span class="token punctuation">;</span>
    ip4_local_addr<span class="token punctuation">.</span>sin_port <span class="token operator">=</span> <span class="token function">htons</span><span class="token punctuation">(</span><span class="token function">ql_soc_generate_port</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    ip4_local_addr<span class="token punctuation">.</span>sin_addr <span class="token operator">=</span> ip4_addr<span class="token punctuation">;</span>

    ret <span class="token operator">=</span> <span class="token function">bind</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token keyword">struct</span> sockaddr <span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">&amp;</span>ip4_local_addr<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>ip4_local_addr<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** bind fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    ip4_svr_addr <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">struct</span> sockaddr_in <span class="token operator">*</span><span class="token punctuation">)</span>res<span class="token operator">-></span>ai_addr<span class="token punctuation">;</span>
    ip4_svr_addr<span class="token operator">-></span>sin_port <span class="token operator">=</span> <span class="token function">htons</span><span class="token punctuation">(</span>WEATHER_PORT<span class="token punctuation">)</span><span class="token punctuation">;</span>

    ret <span class="token operator">=</span> <span class="token function">connect</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token keyword">struct</span> sockaddr <span class="token operator">*</span><span class="token punctuation">)</span>ip4_svr_addr<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span><span class="token keyword">struct</span> sockaddr<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"connect ret: %d, errno: %u\r\n"</span><span class="token punctuation">,</span> ret<span class="token punctuation">,</span> errno<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">==</span> <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">&amp;&amp;</span> errno <span class="token operator">!=</span> EINPROGRESS<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** connect fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    t<span class="token punctuation">.</span>tv_sec <span class="token operator">=</span> TCP_CONNECT_TIMEOUT_S<span class="token punctuation">;</span>
    t<span class="token punctuation">.</span>tv_usec <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token function">FD_ZERO</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">FD_ZERO</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>write_fds<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">FD_SET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">FD_SET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>write_fds<span class="token punctuation">)</span><span class="token punctuation">;</span>

    ret <span class="token operator">=</span> <span class="token function">select</span><span class="token punctuation">(</span>sock_fd <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">,</span> <span class="token operator">&amp;</span>write_fds<span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>t<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"select ret: %d\r\n"</span><span class="token punctuation">,</span> ret<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">&lt;=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** select timeout or error ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token operator">!</span><span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>write_fds<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** connect fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>write_fds<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        optlen <span class="token operator">=</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>sock_error<span class="token punctuation">)</span><span class="token punctuation">;</span>
        ret <span class="token operator">=</span> <span class="token function">getsockopt</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> SOL_SOCKET<span class="token punctuation">,</span> SO_ERROR<span class="token punctuation">,</span> <span class="token operator">&amp;</span>sock_error<span class="token punctuation">,</span> <span class="token operator">&amp;</span>optlen<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">==</span> <span class="token number">0</span> <span class="token operator">&amp;&amp;</span> sock_error <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"connect success\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">else</span>
        <span class="token punctuation">{</span>
            <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** connect fail, sock_err = %d, errno = %u ***\r\n"</span><span class="token punctuation">,</span> sock_error<span class="token punctuation">,</span> errno<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>write_fds<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"connect success\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token operator">!</span><span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>write_fds<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** connect fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** connect fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment" spellcheck="true">/* 组合GET请求包 */</span>
    <span class="token function">sprintf</span><span class="token punctuation">(</span>GetRequestBuf<span class="token punctuation">,</span> GET_REQUEST_PACKAGE<span class="token punctuation">,</span> weather_json<span class="token punctuation">,</span> KEY<span class="token punctuation">,</span> location<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment" spellcheck="true">/* 发送数据到服务端 */</span>
    ret <span class="token operator">=</span> <span class="token function">send</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token keyword">const</span> <span class="token keyword">void</span><span class="token operator">*</span><span class="token punctuation">)</span>GetRequestBuf<span class="token punctuation">,</span> <span class="token function">strlen</span><span class="token punctuation">(</span>GetRequestBuf<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** send fail ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

_recv_<span class="token punctuation">:</span>
    t<span class="token punctuation">.</span>tv_sec <span class="token operator">=</span> TCP_RECV_TIMEOUT_S<span class="token punctuation">;</span>
    t<span class="token punctuation">.</span>tv_usec <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token function">FD_ZERO</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">FD_SET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span><span class="token punctuation">;</span>

    ret <span class="token operator">=</span> <span class="token function">select</span><span class="token punctuation">(</span>sock_fd <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>t<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"select ret: %d\r\n"</span><span class="token punctuation">,</span> ret<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">&lt;=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** select timeout or error ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token function">FD_ISSET</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> <span class="token operator">&amp;</span>read_fds<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        ret <span class="token operator">=</span> <span class="token function">recv</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> WeatherRecvBuf<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>WeatherRecvBuf<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">></span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"recv data: [%d]%s\r\n"</span><span class="token punctuation">,</span> ret<span class="token punctuation">,</span> WeatherRecvBuf<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment" spellcheck="true">/* 解析天气数据并保存到结构体变量weather_data中 */</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token number">0</span> <span class="token operator">==</span> <span class="token function">strcmp</span><span class="token punctuation">(</span>weather_json<span class="token punctuation">,</span> NOW_JSON<span class="token punctuation">)</span><span class="token punctuation">)</span>        <span class="token comment" spellcheck="true">// 天气实况</span>
            <span class="token punctuation">{</span>
                <span class="token function">cJSON_NowWeatherParse</span><span class="token punctuation">(</span>WeatherRecvBuf<span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>    
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span>ret <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** peer closed ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">else</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token punctuation">(</span>errno <span class="token operator">==</span> EINTR <span class="token operator">||</span> errno <span class="token operator">==</span> EWOULDBLOCK <span class="token operator">||</span> errno <span class="token operator">==</span> EAGAIN<span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"*** error occurs ***\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">goto</span> exit<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">else</span>
            <span class="token punctuation">{</span>
                <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"wait for a while\r\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">ql_rtos_task_sleep_ms</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">goto</span> _recv_<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

    <span class="token punctuation">}</span>

exit<span class="token punctuation">:</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>dns_success<span class="token punctuation">)</span> <span class="token function">freeaddrinfo</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>sock_fd <span class="token operator">>=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">struct</span> linger linger <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>

        linger<span class="token punctuation">.</span>l_onoff <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
        linger<span class="token punctuation">.</span>l_linger <span class="token operator">=</span> TCP_CLOSE_LINGER_TIME_S<span class="token punctuation">;</span>

        <span class="token function">setsockopt</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> SOL_SOCKET<span class="token punctuation">,</span> SO_LINGER<span class="token punctuation">,</span> <span class="token operator">&amp;</span>linger<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>linger<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">setsockopt</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">,</span> IPPROTO_TCP<span class="token punctuation">,</span> TCP_CLOSE_TIMEROUT<span class="token punctuation">,</span> <span class="token operator">&amp;</span>linger<span class="token punctuation">.</span>l_linger<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>linger<span class="token punctuation">.</span>l_linger<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment" spellcheck="true">/* 清空缓冲区 */</span>
        <span class="token function">memset</span><span class="token punctuation">(</span>GetRequestBuf<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   
        <span class="token function">memset</span><span class="token punctuation">(</span>WeatherRecvBuf<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token operator">*</span><span class="token number">1024</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    
        <span class="token function">close</span><span class="token punctuation">(</span>sock_fd<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment" spellcheck="true">/*******************************************************************************************************
** 函数: cJSON_NowWeatherParse，解析天气实况数据
**------------------------------------------------------------------------------------------------------
** 参数: JSON：天气数据包   result：数据解析的结果
** 返回: void
********************************************************************************************************/</span>
<span class="token keyword">static</span> <span class="token keyword">int</span> <span class="token function">cJSON_NowWeatherParse</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>JSON<span class="token punctuation">,</span> Weather <span class="token operator">*</span>result<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    cJSON <span class="token operator">*</span>json<span class="token punctuation">,</span><span class="token operator">*</span>arrayItem<span class="token punctuation">,</span><span class="token operator">*</span>object<span class="token punctuation">,</span><span class="token operator">*</span>subobject<span class="token punctuation">,</span><span class="token operator">*</span>item<span class="token punctuation">;</span>

    json <span class="token operator">=</span> <span class="token function">cJSON_Parse</span><span class="token punctuation">(</span>JSON<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//解析JSON数据包</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>json <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>          <span class="token comment" spellcheck="true">//检测JSON数据包是否存在语法上的错误，返回NULL表示数据包无效</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Error before: [%s]\n"</span><span class="token punctuation">,</span><span class="token function">cJSON_GetErrorPtr</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//打印数据包语法错误的位置</span>
        <span class="token keyword">return</span> <span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>arrayItem <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>json<span class="token punctuation">,</span><span class="token string">"results"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//匹配字符串"results",获取数组内容</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">int</span> size <span class="token operator">=</span> <span class="token function">cJSON_GetArraySize</span><span class="token punctuation">(</span>arrayItem<span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment" spellcheck="true">//获取数组中对象个数</span>
<span class="token macro property">#<span class="token directive keyword">if</span> DEBUG</span>
            <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"cJSON_GetArraySize: size=%d\n"</span><span class="token punctuation">,</span>size<span class="token punctuation">)</span><span class="token punctuation">;</span> 
<span class="token macro property">#<span class="token directive keyword">endif</span></span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>object <span class="token operator">=</span> <span class="token function">cJSON_GetArrayItem</span><span class="token punctuation">(</span>arrayItem<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span><span class="token comment" spellcheck="true">//获取父对象内容</span>
            <span class="token punctuation">{</span>
                <span class="token comment" spellcheck="true">/* 匹配子对象1：城市地区相关 */</span>
                <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>subobject <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span><span class="token string">"location"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    <span class="token comment" spellcheck="true">// 匹配id</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"id"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>   
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>id<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>         <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                    <span class="token punctuation">}</span>
                    <span class="token comment" spellcheck="true">// 匹配城市名</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"name"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> 
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>name<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>         <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                    <span class="token punctuation">}</span>
                    <span class="token comment" spellcheck="true">// 匹配城市所在的国家</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"country"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>country<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                    <span class="token punctuation">}</span>
                    <span class="token comment" spellcheck="true">// 匹配完整地名路径</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"path"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>  
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>path<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>         <span class="token comment" spellcheck="true">// 保存数据供外部调用    </span>
                    <span class="token punctuation">}</span>
                    <span class="token comment" spellcheck="true">// 匹配时区</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"timezone"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>timezone<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment" spellcheck="true">// 保存数据供外部调用    </span>
                    <span class="token punctuation">}</span>
                    <span class="token comment" spellcheck="true">// 匹配时差</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"timezone_offset"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>timezone_offset<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                    <span class="token punctuation">}</span>
                <span class="token punctuation">}</span>
                <span class="token comment" spellcheck="true">/* 匹配子对象2：今天的天气情况 */</span>
                <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>subobject <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span><span class="token string">"now"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    <span class="token comment" spellcheck="true">// 匹配天气现象文字</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"text"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>text<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                    <span class="token punctuation">}</span>
                    <span class="token comment" spellcheck="true">// 匹配天气现象代码</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"code"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>code<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                    <span class="token punctuation">}</span>
                    <span class="token comment" spellcheck="true">// 匹配气温</span>
                    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>subobject<span class="token punctuation">,</span><span class="token string">"temperature"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> 
                    <span class="token punctuation">{</span>
                        <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>temperature<span class="token punctuation">,</span> item<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>item<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                    <span class="token punctuation">}</span>    
                <span class="token punctuation">}</span>
                <span class="token comment" spellcheck="true">/* 匹配子对象3：数据更新时间（该城市的本地时间） */</span>
                <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>subobject <span class="token operator">=</span> <span class="token function">cJSON_GetObjectItem</span><span class="token punctuation">(</span>object<span class="token punctuation">,</span><span class="token string">"last_update"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    <span class="token function">memcpy</span><span class="token punctuation">(</span>result<span class="token operator">-></span>last_update<span class="token punctuation">,</span> subobject<span class="token operator">-></span>valuestring<span class="token punctuation">,</span><span class="token function">strlen</span><span class="token punctuation">(</span>subobject<span class="token operator">-></span>valuestring<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment" spellcheck="true">// 保存数据供外部调用</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span> 
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token function">cJSON_Delete</span><span class="token punctuation">(</span>json<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//释放cJSON_Parse()分配出来的内存空间</span>

    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment" spellcheck="true">/*******************************************************************************************************
** 函数: DisplayWeather，显示天气数据
**------------------------------------------------------------------------------------------------------
** 参数: weather_data：天气数据
** 返回: void
********************************************************************************************************/</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">DisplayWeather</span><span class="token punctuation">(</span>Weather <span class="token operator">*</span>weather_data<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"============%s today weather===========\n"</span><span class="token punctuation">,</span> weather_data<span class="token operator">-></span>name<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"weather_data->text: %s\n"</span><span class="token punctuation">,</span> weather_data<span class="token operator">-></span>text<span class="token punctuation">)</span><span class="token punctuation">;</span>        
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"weather_data->temperature: %s\n"</span><span class="token punctuation">,</span> weather_data<span class="token operator">-></span>temperature<span class="token punctuation">)</span><span class="token punctuation">;</span>    
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"weather_data->timezone: %s\n"</span><span class="token punctuation">,</span> weather_data<span class="token operator">-></span>timezone<span class="token punctuation">)</span><span class="token punctuation">;</span>    
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"weather_data->timezone_offset: %s\n"</span><span class="token punctuation">,</span> weather_data<span class="token operator">-></span>timezone_offset<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"weather_data->last_update: %s\n"</span><span class="token punctuation">,</span> weather_data<span class="token operator">-></span>last_update<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token function">application_init</span><span class="token punctuation">(</span>sockets_weather_test<span class="token punctuation">,</span> <span class="token string">"sockets_weather_test"</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
<p>关于天气获取、解析代码之前已经有详细分享过，这里不再解释。相关文章：</p>
<p><a href="https://t.1yb.co/13rS" target="_blank" rel="noopener">【<em>socket</em>应用】基于C语言的天气客户端的实现</a></p>
<p>测试结果：</p>
<p><img src="https://s1.ax1x.com/2020/07/03/NvilSs.png" alt></p>
<hr>
<p>我的个人博客：<a href="https://www.lizhengnian.cn/">https://www.lizhengnian.cn/</a></p>
<p>我的微信公众号：嵌入式大杂烩</p>
<p>我的CSDN博客：<a href="https://blog.csdn.net/zhengnianli" target="_blank" rel="noopener">https://blog.csdn.net/zhengnianli</a></p>
<p><img src="https://s1.ax1x.com/2020/06/28/NgPwRK.png" alt></p>

            </div>
            <hr>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">欢迎关注ZhengN的微信公众号</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <!--<ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微信公众号</a></li>
                    </ul>-->
					<!--
                    <div id="alipay">
                        <img src="" class="reward-img" alt="支付宝打赏二维码">
                    </div>
					-->
                    <div id="wechat">
                        <img src="/medias/reward/wechat.jpg" class="reward-img" alt="微信公众号二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            


        </div>
    </div>

    

    

    

    

    
        <style>
    .valine-card {
        margin: 1.5rem auto;
    }

    .valine-card .card-content {
        padding: 20px 20px 5px 20px;
    }

    #vcomments input[type=text],
    #vcomments input[type=email],
    #vcomments input[type=url],
    #vcomments textarea {
        box-sizing: border-box;
    }

    #vcomments p {
        margin: 2px 2px 10px;
        font-size: 1.05rem;
        line-height: 1.78rem;
    }

    #vcomments blockquote p {
        text-indent: 0.2rem;
    }

    #vcomments a {
        padding: 0 2px;
        color: #42b983;
        font-weight: 500;
        text-decoration: underline;
    }

    #vcomments img {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    #vcomments ol li {
        list-style-type: decimal;
    }

    #vcomments ol,
    ul {
        display: block;
        padding-left: 2em;
        word-spacing: 0.05rem;
    }

    #vcomments ul li,
    ol li {
        display: list-item;
        line-height: 1.8rem;
        font-size: 1rem;
    }

    #vcomments ul li {
        list-style-type: disc;
    }

    #vcomments ul ul li {
        list-style-type: circle;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    #vcomments table, th, td {
        border: 0;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments h1 {
        font-size: 1.85rem;
        font-weight: bold;
        line-height: 2.2rem;
    }

    #vcomments h2 {
        font-size: 1.65rem;
        font-weight: bold;
        line-height: 1.9rem;
    }

    #vcomments h3 {
        font-size: 1.45rem;
        font-weight: bold;
        line-height: 1.7rem;
    }

    #vcomments h4 {
        font-size: 1.25rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    #vcomments h5 {
        font-size: 1.1rem;
        font-weight: bold;
        line-height: 1.4rem;
    }

    #vcomments h6 {
        font-size: 1rem;
        line-height: 1.3rem;
    }

    #vcomments p {
        font-size: 1rem;
        line-height: 1.5rem;
    }

    #vcomments hr {
        margin: 12px 0;
        border: 0;
        border-top: 1px solid #ccc;
    }

    #vcomments blockquote {
        margin: 15px 0;
        border-left: 5px solid #42b983;
        padding: 1rem 0.8rem 0.3rem 0.8rem;
        color: #666;
        background-color: rgba(66, 185, 131, .1);
    }

    #vcomments pre {
        font-family: monospace, monospace;
        padding: 1.2em;
        margin: .5em 0;
        background: #272822;
        overflow: auto;
        border-radius: 0.3em;
        tab-size: 4;
    }

    #vcomments code {
        font-family: monospace, monospace;
        padding: 1px 3px;
        font-size: 0.92rem;
        color: #e96900;
        background-color: #f8f8f8;
        border-radius: 2px;
    }

    #vcomments pre code {
        font-family: monospace, monospace;
        padding: 0;
        color: #e8eaf6;
        background-color: #272822;
    }

    #vcomments pre[class*="language-"] {
        padding: 1.2em;
        margin: .5em 0;
    }

    #vcomments code[class*="language-"],
    pre[class*="language-"] {
        color: #e8eaf6;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }

    #vcomments b,
    strong {
        font-weight: bold;
    }

    #vcomments dfn {
        font-style: italic;
    }

    #vcomments small {
        font-size: 85%;
    }

    #vcomments cite {
        font-style: normal;
    }

    #vcomments mark {
        background-color: #fcf8e3;
        padding: .2em;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }
</style>

<div class="card valine-card" data-aos="fade-up">
    <div id="vcomments" class="card-content"></div>
</div>

<script src="/libs/valine/av-min.js"></script>
<script src="/libs/valine/Valine.min.js"></script>
<script>
    new Valine({
        el: '#vcomments',
        appId: 'Vc276uuqkd8y8heuqzShe9p1-gzGzoHsz',
        appKey: 'bUwy6lANpgeVdpcQamMtC8QD',
        notify: 'false' === 'true',
        verify: 'false' === 'true',
        visitor: 'true' === 'true',
        avatar: 'mm',
        pageSize: '10',
        lang: 'zh-cn',
        placeholder: '快来快活呀！^_^'
    });
</script>
    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fa fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2020/06/29/4g-mo-kuai-xiao-xiong-pai-4g-kai-fa-ban-chu-ti-yan/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/2.jpg" class="responsive-img" alt="【4G模块】小熊派4G开发板初体验">
                        
                        <span class="card-title">【4G模块】小熊派4G开发板初体验</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            开发板硬件资源介绍前阵子小熊派发布了一款超高性价比的4G开发板（19.8元包邮），但是板子仅限量1000套。小熊派官方给我送了一块，我们一起来学习学习：

板子做得小巧精致，控制核心用的是移远的EC100Y LTE Cat1无线通信模组，该
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2020-06-29
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/嵌入式/" class="post-category" target="_blank">
                                    嵌入式
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/4G/" target="_blank">
                        <span class="chip bg-color">4G</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fa fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/06/25/stm32-yi-chong-jian-dan-shi-yong-de-ce-liang-cheng-xu-kuai-yun-xing-shi-jian-de-fang-fa/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/0.jpg" class="responsive-img" alt="【STM32】一种简单、实用的测量程序块运行时间的方法">
                        
                        <span class="card-title">【STM32】一种简单、实用的测量程序块运行时间的方法</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            前言平时我们可能很少去关注程序运行的时间，但是在一些情况下可能需要对程序进行一个整体的复盘、优化。那么，程序运行的时间就是一个可以考虑的方面，可以测一下某些代码块、函数、算法的运行时间，然后整体考虑看看有没有必要进行优化。
之前在某工控类项
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2020-06-25
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/STM32/" class="post-category" target="_blank">
                                    STM32
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/运行时间/" target="_blank">
                        <span class="chip bg-color">运行时间</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="fa fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fa fa-list"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).slideUp(500);
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).slideDown(500);
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站由&copy;<a href="https://zhengnianli.github.io/" target="_blank">ZhengNian</a>基于
            <a href="https://hexo.io/" target="_blank">Hexo</a> 的
            <a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">hexo-theme-matery</a>主题搭建.

            
                &nbsp;<i class="fa fa-area-chart"></i>&nbsp;站点总字数:&nbsp;
                <span class="white-color">187.2k</span>
            

            
			
                <br>
                
                <span id="busuanzi_container_site_pv">
                    <i class="fa fa-heart-o"></i>
                    本站总访问量 <span id="busuanzi_value_site_pv" class="white-color"></span>
                </span>
                
                
                <span id="busuanzi_container_site_uv">
                    <i class="fa fa-users"></i>
                    次,&nbsp;访客数 <span id="busuanzi_value_site_uv" class="white-color"></span> 人.
                </span>
                
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/zhengnianli" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fa fa-github"></i>
    </a>



    <a href="mailto:2238184039@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fa fa-envelope-open"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2238184039" class="tooltipped" data-tooltip="QQ联系我: 2238184039" data-position="top" data-delay="50">
        <i class="fa fa-qq"></i>
    </a>



    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fa fa-rss"></i>
    </a>
</div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fa fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字" class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->



    <script src="/libs/others/clicklove.js"></script>


    <script async src="/libs/others/busuanzi.pure.mini.js"></script>


</body>
</html>